
class Reactor
{
public:
};

class ACE_Event_Handler
{
public:
	virtual int handle_input(ACE_HANDLE){ return 0; }
	virtual int handle_output(ACE_HANDLE){ return 0; }
	virtual int handle_timeout(ACE_HANDLE){ return 0; }
	virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask){ return 0; }
	
	Reactor* reactor()
	{
		return reactor_;
	}
private:
	Reactor* reactor_;
};

class Client_Acceptor : public ACE_Event_Handler
{
public:
	int handle_input(HANDLE)
	{
		Torrent_Handler torrentHandler = new Torrent_Handler(reactor());
		if (torrentHandler == NULL)
			return -1;
			
		reactor()->register_hander(torrentHandler, MASK_READ | MASK_WRITE);
	}
	int handle_close(HANDLE)
	{ delete this; return 0; }
};

template<REACTOR>
class Torrent_Handler : public Event_Handler
{
public:
	Torrent_Handler(ACE_Reactor* reactor) : reactor_(reactor) {}
	int handle_close(HANDLE)
	{ delete this; return 0; }
}

class Client
{
};
socc_set:function()
{
	var socc_fd, vecSocc;
	foreach(socc_fd fd in vecSocc)
	{
		int nRet = 0;
		if ((nRet = check_fd(fd)) == -1)
			return -1;

		if (nRet > 0 && (nRet = 0, nRet = dispatch_fd(fd)) == -1)
			return -1;
	}
},
socc_fd:function(fd)
{
	fd_ = fd;
},
~socc_fd:function()
{
	if (fd_ != -1) closesocc(fd_);
	fd_ = -1;
},
check_fd:function(fd)
{
	if (fd == -1) return -1;
	
	return is_in_set(fd);
},
//as manipulate file, which is unique for each thread, use multithread
dispatch_fd:function(fd)
{
},
class acceptor
{
public:
	socket socket_;
};
